package com.cby.project.mvi.data

import com.cby.project.mvi.bean.NewsItemBean
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET

/**
 * @description: NewApi
 *
 * @author ChenBaoyang
 * @date 2021/12/4 10:39
 */
interface NewApi {

    @GET("mock")
    fun getArticles(): List<NewsItemBean>?

    companion object {

        private const val BASE_URL = "https://your_api_endpoint.com/"

        private val okHttpClient: OkHttpClient = OkHttpClient()
            .newBuilder()
            .addInterceptor(MockInterceptor())
            .build()

        fun create(): NewApi {
            return Retrofit
                .Builder()
                .client(okHttpClient)
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(NewApi::class.java)


        }
    }
}